package com.boot.main.controller;

import com.boot.main.entity.ScomOrderProduct;
import com.boot.main.service.IOrderProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/v1/api")
@Api(tags = "订单产品管理")
public class OrderProductController {
    @Resource
    private IOrderProductService orderProductService;

    @RequestMapping(value="/orderProducts", method = RequestMethod.GET)
    @ApiOperation(value="获取订单产品列表")
    public Object getOrderProducts(@RequestParam("page") Integer page, @RequestParam("limit") Integer limit, @RequestParam("name") String name){
        return orderProductService.getOrderProducts(page, limit, name);
    }

    @RequestMapping(value="/orderProduct", method = RequestMethod.POST)
    @ApiOperation(value="新增订单产品")
    public Object saveOrderProduct(@RequestBody ScomOrderProduct orderProduct){
        return orderProductService.saveOrderProduct(orderProduct);
    }

    @RequestMapping(value="/orderProduct/{id}", method = RequestMethod.DELETE)
    @ApiOperation(value="删除订单产品")
    public Object deleteOrderProduct(@PathVariable Long id){
        return orderProductService.deleteOrderProduct(id);
    }
}
